Manipulating gl_LightSource[gl_MaxLights]

Posted by pion on Stack Overflow See other posts from Stack Overflow or by pion
Published on 2010-12-27T21:53:17Z Indexed on 2011/01/02 18:54 UTC
Read the original article Hit count: 105

Filed under:

The The OpenGL ® Shading Language Spec version 1.20 http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf shows the following:

struct gl_LightSourceParameters {
vec4  ambient;             // Acli
vec4  diffuse;             // Dcli
vec4  specular;            // Scli
vec4  position;            // Ppli
vec4  halfVector;          // Derived: Hi
vec3  spotDirection;       // Sdli
float spotExponent;        // Srli
float spotCutoff;          // Crli
                           // (range: [0.0,90.0], 180.0)
float spotCosCutoff;       // Derived: cos(Crli)
                           // (range: [1.0,0.0],-1.0)
float constantAttenuation; // K0
float linearAttenuation;   // K1
float quadraticAttenuation;// K2
};

    uniform gl_LightSourceParameters  gl_LightSource[gl_MaxLights];

Also, http://www.lighthouse3d.com/opengl/glsl/index.php?ogldir1 shows the following code snippets:

lightDir = normalize(vec3(gl_LightSource[0].position));

https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html#5.10 shows many uniform* functions but nothing seems to deal with an array of uniform variable like gl_LightSource[0].

How do we set the gl_LightSource[0] fields in WebGL using JavaScript? For example, gl_LightSource[0].position

Thanks in advance for your help.

Note: Cross post on http://www.khronos.org/message_boards/viewtopic.php?f=43&t=3373

© Stack Overflow or respective owner

Related posts about webgl